<?php
$q=$_GET["q"];
$array= explode(",",$q);
$pro=$array[0];
$School_Id=$array[1];
$Access_Type=$array[2];
$Id=$Access_Type.",".$School_Id.",School_Id";
$hint="";
$nothing="";
$first_option="";
include_once '../Login/databaseconnection.php';
$tra_id=mysql_query("SELECT * FROM programme WHERE Programme_Name='$pro'");
if($row=mysql_fetch_array($tra_id))
{
$Programme_Id=$row['Programme_Id'];
}
if($pro!="Select One"&&$School_Id!="")
{
$hint=$hint.'<label>Year:</label>';
$hint=$hint."<select name='Programme_Year' id='$School_Id' onChange='getdetails(this.value,this.id)' onmouseover='clearpopbox()'>";
$years=mysql_query("SELECT DISTINCT(Year) FROM programmes WHERE Programme_Id='$Programme_Id' AND School_Id='$School_Id'");
if($years)
{
while($row_years=mysql_fetch_array($years))
{
$Year=$row_years['Year'];
$hint=$hint.'<option value="'.$Year.'">'.$Year.'</option>';
$nothing="false";
if(empty($first_option))
{
$first_option=$Year;
}
}
}
if($nothing!="false")
{
$hint=$hint.'<option value="">No result</option>';
}
$hint=$hint.'</select><br/><div id="prodetails">';
$prog=mysql_query("SELECT * FROM programmes WHERE Programme_Id='$Programme_Id' AND Year='$first_option' AND School_Id='$School_Id'");
if($prog)
{
if($row_prog=mysql_fetch_array($prog))
{
$Pro_Male_Students=$row_prog['No_Of_Male_Students'];
$Availability_Tea_Guides=$row_prog['Availability_Tguides'];
$Availability_Books=$row_prog['Availability_Books'];
$Required_Teachers=$row_prog['Required_Teachers'];
$Trained_Teachers=$row_prog['Trained_Teachers'];
$Teachers_In_Training=$row_prog['Teachers_In_Training'];
$Pro_Female_Students=$row_prog['No_Of_Female_Students'];
}
else
{
$Pro_Male_Students='0';
$Availability_Tea_Guides='_';
$Availability_Books='_';
$Required_Teachers='0';
$Trained_Teachers='0';
$Teachers_In_Training='0';
$Pro_Female_Students='0';
}
}
 $hint=$hint.'<table height="200" class="imgholder">
       <tr>
        <th>        
        </th>
         <td>
        </td>
         </tr> 
      <tr>
        <th>        
         <label>Number of male students:</label>
         </th>
         <td>';
         $hint=$hint."<input type='text' name='Pro_Male_Students' value='$Pro_Male_Students' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         <tr>
        <th>        
         <label>Number of female students:</label>
         </th>
         <td>';
        $hint=$hint."<input type='text' name='Pro_Female_Students' value='$Pro_Female_Students' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         <tr>
        <th>        
         <label>Number of teachers in training:</label>
         </th>
         <td>';
		 /*
if($Teachers_In_Training!="0")
{
$hint=$hint."<input type='text' name='Teachers_In_Training' value='$Teachers_In_Training' readonly='readonly' id='$Id' onmouseover='getdetails_popup(this.name,this.id)'/>";
}
else
{
$hint=$hint."<input type='text' name='Teachers_In_Training' value='$Teachers_In_Training' readonly='readonly' onmouseover='clearpopbox()'/>";
}
*/
$hint=$hint."<input type='text' name='Teachers_In_Training' value='$Teachers_In_Training' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         <tr>
        <th>        
         <label>Number of trained teachers:</label>
         </th>
         <td>';
		 /*
if($Trained_Teachers!="0")
{
$hint=$hint."<input type='text' name='Trained_Teachers' value='$Trained_Teachers' readonly='readonly' id='$Id' onmouseover='getdetails_popup(this.name,this.id)'/>";
}
else
{
$hint=$hint."<input type='text' name='Trained_Teachers' value='$Trained_Teachers' readonly='readonly' onmouseover='clearpopbox()'/>";
}
*/
$hint=$hint."<input type='text' name='Trained_Teachers' value='$Trained_Teachers' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         <tr>
        <th>        
         <label>Required teachers:</label>
         </th>
         <td>';
        $hint=$hint."<input type='text' name='Required_Teachers' value='$Required_Teachers' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         <tr>
        <th>        
         <label>Availability of books:</label>
         </th>
         <td>';
        $hint=$hint."<input type='text' name='Availability_Books' value='$Availability_Books' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         <tr>
        <th>        
         <label>Availability of teachers guides:</label>
         </th>
         <td>';
        $hint=$hint."<input type='text' name='Availability_Tea_Guides' value='$Availability_Tea_Guides' readonly='readonly' onmouseover='clearpopbox()'/>";
$hint=$hint.'</td>
         </tr>
         </table></div>';
}
if($pro=="Select One"||$hint==""||$hint=="<label>Year:</label><select name='Programme_Year' id='$School_Id' onChange='getdetails(this.value,this.id)'></select>")
{
$response="<label>Year:</label><select name='Programme_Year' id='Programme_Year' onChange='getdetails(this.value)'><option value=''>No result</option></select><br/><div id='prodetails'>";

}
else
{
$response=$hint;
}
echo $response;
?>